﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/BMP_Edit.master" AutoEventWireup="true"
    CodeFile="Edit.aspx.cs" Inherits="Pages_TUser_Edit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">
        var treeULID = "treeUL";
        var modelName = "TOUInfo";
        var checkedArray = new Array();
        var isLoading = false;

        $().ready(function () {
            InitCheckArray();
            $('#' + treeULID).tree({
                checkbox: true,
                url: vRoot + 'Services/Handler.ashx?Type=' + modelName + '&PGID=0',
                height: 400,
                cascadeCheck: false,
                onBeforeLoad: function (row, param) {
                    isLoading = true;
                    if (row) {
                        $(this).tree('options').url = vRoot + 'Services/Handler.ashx?Type=' + modelName + '&PGID=' + row.id;
                    } else {
                        $(this).tree('options').url = vRoot + 'Services/Handler.ashx?Type=' + modelName + '&PGID=0';
                    }
                },
                onClick: function (node) {
                    $(this).tree('toggle', node.target);
                },
                onLoadSuccess: function () {
                    isLoading = false;
                    InitChecked();
                },
                onCheck: function (node, checked) {
                    if (!isLoading)
                        OnNodeChecked(node, checked);
                },
                onLoadError: function (e) {
                    alert(e);
                }
            });
        });

        function InitChecked() {
            checkedArray.HashForEach(function (item) {
                var node = $('#' + treeULID).tree('find', item);
                if (node && !node.checked) {
                    isInitChecked = true;
                    $('#' + treeULID).tree('check', node.target);
                    isInitChecked = false;
                }
            });
        }

        function InitCheckArray() {
            var arr = $("#checkedIDs").val().split(',');
            for (i = 0; i < arr.length; i++) {
                checkedArray[arr[i]] = arr[i];
            }
        }

        function OnNodeChecked(node, cheked) {
            if (isInitChecked)
                return;
            var idarray = treeCheckIds.Trim(',').split(',');
            if (cheked) {
                for (var i = 0; i < idarray.length; i++) {
                    checkedArray[idarray[i]] = idarray[i];
                }

            }
            else {
                for (var i = 0; i < idarray.length; i++) {
                    delete checkedArray[idarray[i]];
                }
            }
            treeCheckIds = "";
        }
        //得到当前界面选择的全部节点
        function GetCheckedNodes() {
            var c = "";
            var p = "";
            $(".tree-checkbox1").parent().children('.tree-title').each(function () {
                c += $(this).parent().attr('node-id') + ",";
            });
            $(".tree-checkbox2").parent().children('.tree-title').each(function () {
                p += $(this).parent().attr('node-id') + ",";
            });
            var str = (c + p);
            str = str.Trim(',');
            return str;
        }

        //将当前选择的界面，与历史节点进行叠加，得到最终权限。OnEditDetailSubmit
        function OnSubmitExtend() {
            var result = GetCheckedNodes().split(',');
            for (var i = 0; i < result.length; i++) {
                checkedArray[result[i]] = result[i];
            }
            var data = checkedArray.KeyToString().Trim(',');
            $("#checkedIDs").val(data);
            return true;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="contentPlaceHolder" runat="Server">
    <div id="tab1">
        <asp:HiddenField ID="checkedIDs" runat="server" ClientIDMode="Static" />
        <table class="editTable" cellpadding="0" cellspacing="0">
            <tr>
                <th>
                    用户名(<label style="color: Red">*</label>)：
                </th>
                <td>
                    <input id="TUserInfo_UID" type="text" emp="true" unq="true" des="用户名" exp="reg_UID"
                        runat="server" />
                </td>
                <th>
                    姓名(<label style="color: Red">*</label>)：
                </th>
                <td>
                    <input id="TUserInfo_Name" type="text" emp="true" des="姓名" runat="server" />
                </td>
            </tr>
            <tr runat="server" id="PWD">
                <th>
                    密码(<label style="color: Red">*</label>)：
                </th>
                <td>
                    <input id="TUserInfo_PWD" type="password" runat="server" emp="true" des="密码" />
                </td>
                <th>
                    确认密码(<label style="color: Red">*</label>)：
                </th>
                <td>
                    <input id="confirmPWD" type="password" emp="true" des="确认密码" exp="Compare_<%=TUserInfo_PWD.ClientID %>" />
                </td>
            </tr>
            <tr>
                <th>
                    性别：
                </th>
                <td>
                    <asp:DropDownList ID="TUserInfo_Sex" runat="server" des="性别">
                        <asp:ListItem Text="男" Value="1"></asp:ListItem>
                        <asp:ListItem Text="女" Value="2"></asp:ListItem>
                    </asp:DropDownList>
                </td>
                <th>
                    生日：
                </th>
                <td>
                    <input id="TUserInfo_BirthDay" type="text" onclick="WdatePicker();" runat="server"
                        des="生日" />
                </td>
            </tr>
            <tr>
                <th>
                    工号：
                </th>
                <td>
                    <input id="TUserInfo_NO" type="text" runat="server" des="工号" />
                </td>
                <th>
                    电子邮件：
                </th>
                <td>
                    <input id="TUserInfo_EMail" type="text" runat="server" des="电子邮件" exp="reg_EMail" />
                </td>
            </tr>
            <tr>
                <th>
                    电话：
                </th>
                <td>
                    <input id="TUserInfo_Tel" type="text" runat="server" des="电话" exp="reg_Tel" />
                </td>
                <th>
                    移动电话：
                </th>
                <td>
                    <input id="TUserInfo_Mobile" type="text" runat="server" des="移动电话" exp="reg_Mobile" />
                </td>
            </tr>
            <tr>
                <th>
                    QQ：
                </th>
                <td>
                    <input id="TUserInfo_QQ" type="text" runat="server" des="QQ" exp="reg_QQ" />
                </td>
                <th>
                    MSN：
                </th>
                <td>
                    <input id="TUserInfo_MSN" type="text" runat="server" des="MSN" />
                </td>
            </tr>
            <tr>
                <th>
                    是否启用：
                </th>
                <td>
                    <input id="TUserInfo_IsEnable" type="checkbox" runat="server" />
                </td>
            </tr>
        </table>
    </div>
    <div id="tab2">
        <table class="editTable" cellpadding="0" cellspacing="0">
            <tr>
                <th>
                    所属角色：
                </th>
                <td colspan="3">
                    <asp:ListBox AutoPostBack="false" SelectionMode="Multiple" runat="server" ID="Roles">
                    </asp:ListBox>
                </td>
            </tr>
            <tr>
                <th>
                    所属机构：
                </th>
                <td colspan="3">
                    <ul id="treeUL">
                    </ul>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
